package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;
@Mapper
public interface DishFlavorMapper {
    /**
     * 添加口味信息
     * @param flavors 口味信息和 菜品ID
     */
    void insertBatch(@Param("flavors") List<DishFlavor> flavors);

    /**
     * 统计关联个数
     * @param ids 菜品ID
     * @return 关联个数
     */
    Long selectDish(@Param("ids") List<Long> ids);

    /**
     * 根据菜品ID获取口味信息
     * @param id 菜品ID
     * @return 口味信息
     */
    @Select("select * from dish_flavor where dish_id =#{id}")
    List<DishFlavor> getDish(Long id);

    /**
     * 基于菜品ID删除口味
     * @param id 菜品ID
     */
    @Delete("delete from dish_flavor where dish_id=#{id}")
    void deleteByIdFlavor(Long id);
    @Select("select * from dish_flavor where dish_id = #{id}")
    List<DishFlavor> getByDishId(Long id);

}
